package xyz.zhzby.cyzx.acl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import xyz.zhzby.cyzx.acl.entity.UserRole;
import xyz.zhzby.cyzx.acl.mapper.UserRoleMapper;
import xyz.zhzby.cyzx.acl.service.IUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户-角色关联表 服务实现类
 * </p>
 *
 * @author zby
 * @since 2021-12-07
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {

    @Override
    public void removeByRoleId(Long roleId) {
        LambdaQueryWrapper<UserRole> qw = new LambdaQueryWrapper<>();
        qw.eq(UserRole::getRoleId, roleId);
        baseMapper.delete(qw);
    }

    @Override
    public void removeByUserId(Long userId) {
        LambdaQueryWrapper<UserRole> qw = new LambdaQueryWrapper<>();
        qw.eq(UserRole::getUserId, userId);
        baseMapper.delete(qw);
    }
}
